<template>
  <view class="container">
    <view class="header_txt">
      <view class="back"
            @click="backHandler">
        <image src="/static/img/back3.png"></image>
      </view>
      <view class="title"> 时政热点 </view>
    </view>
    <view class="box">
      <view class="kong_box"></view>
      <view class="input_box">
        <input type="text"
               placeholder-class="placeholder"
               v-model='questiontitle'
               placeholder="请输入提问标题" />
      </view>
      <textarea class="text_center"
                placeholder-class="placeholder"
                v-model='content'
                placeholder="请输入问题详细内容" />
      <view class="quanxian flexs1">
        <view class="">查看权限</view>
        <view class="flexs1">
          <image v-if="chooses"
                 @click="chooseimage"
                 class="choosei"
                 src="../../static/image/ddjs_ico_xz_sel@2x.png"
                 mode=""></image>
          <image v-else
                 class="choosei"
                 @click="chooseimage"
                 src="../../static/image/ddjs_ico_xz_nor@2x.png"
                 mode=""></image>
          <view class="text_use">所有用户</view>
        </view>
        <view class="flexs1">
          <image class="choosei"
                 @click="chooseimage"
                 v-if="chooses"
                 src="../../static/image/ddjs_ico_xz_nor@2x.png"
                 mode=""></image>
          <image class="choosei"
                 @click="chooseimage"
                 v-else
                 src="../../static/image/ddjs_ico_xz_sel@2x.png"
                 mode=""></image>

          <view class="text_ping">仅平台</view>
        </view>
      </view>
      <view class="btns flexs"
            @click='entrue'>确认</view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      chooses: true, //默认所有用户
      type: 1,
      questiontitle: '',
      content: '',
      id: null
    }
  },
  onLoad(options) {
    this.id = options.id
    console.log(options)
  },
  methods: {
    //Curriculum/question
    async entrue() {
      const { data } = await this.$http.post('/Curriculum/question', { c_id: this.id, type: this.type, title: this.questiontitle, content: this.content })
      console.log(data)
      if (data.code == 1) {
        uni.navigateBack({
          delta: 1
        })
      }
    },
    chooseimage() {
      this.chooses = !this.chooses
      if (this.chooses) {
        this.type = 1
      } else {
        this.type = 2
      }
    },
    backHandler() {
      uni.navigateBack({
        delta: 1
      })
    }
  }
}
</script>

<style lang="scss">
.flexs1 {
  display: flex;
  justify-content: flex-start;
}
/* 头部区域 */
.header_txt {
  width: 750rpx;
  overflow: hidden;
  height: 88rpx;
  line-height: 88rpx;
  background-color: #fff;

  .back {
    position: absolute;
    top: 14rpx;
    left: 14rpx;
    width: 60rpx;
    height: 60rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    image {
      width: 48rpx;
      height: 48rpx;
    }
  }

  .right {
    position: absolute;
    top: 14rpx;
    right: 14rpx;
    width: 60rpx;
    height: 60rpx;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .title {
    text-align: center;
    height: 88rpx;
    // margin-top: -20rpx;
    font-size: 32rpx;
    font-weight: bold;
  }
}
.box {
  width: 100%;
  height: 100%;
  background-color: #f5f5f5;
}
.kong_box {
  width: 100%;
  height: 20rpx;
  background-color: #f5f5f5;
}
.choosei {
  width: 26rpx;
  height: 26rpx;
  margin: 35rpx 10rpx 35rpx 50rpx;
}
.input_box {
  width: 690rpx;
  height: 80rpx;
  background: #ffffff;
  border-radius: 10rpx;
  margin: 0rpx auto 0;
}
.input_box input {
  width: 100%;
  height: 80rpx;
  padding-left: 20rpx;
}
.placeholder {
  font-size: 28rpx;
  color: #999999;
}
.text_center {
  width: 690rpx;
  height: 300rpx;
  background: #ffffff;
  border-radius: 10rpx;
  margin: 20rpx auto 0;
  padding: 20rpx 0 0 20rpx;
}
.quanxian {
  width: 690rpx;
  height: 100rpx;
  line-height: 100rpx;
  background: #ffffff;
  border-radius: 10rpx;
  margin: 20rpx auto 0;
  font-size: 28rpx;
  padding-left: 20rpx;
}
.text_use {
  font-size: 26rpx;
}
.text_ping {
  font-size: 26rpx;
  color: #999999;
}
.btns {
  width: 650rpx;
  height: 88rpx;
  line-height: 88rpx;
  text-align: center;
  background: #ffdd47;
  border-radius: 10rpx;
  font-size: 30rpx;
  margin: 60rpx auto 0;
}
</style>
